//返回城市数据,坐标等信息
export function initMap() {
    return new Promise((reslove, reject) => {
      AMap.plugin("AMap.CitySearch", function () {
        var citySearch = new AMap.CitySearch();
        citySearch.getLocalCity(function (status, result) {
          if (status === "complete" && result.info === "OK") {
            reslove(result);
          }else{
              reject('数据获取错误')
          }
        });
      });
    });
  }
//   设置标识等
  export function newMap(res){
    var map = new AMap.Map("map", {
             zoom: 11, //级别
             center: [res.bounds.getCenter().lng, res.bounds.getCenter().lat], //中心点坐标
             viewMode: "2D", //使用3D视图
           });
           let marker = new AMap.Marker({
             icon:
               "//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png",
             position: [res.bounds.getCenter().lng, res.bounds.getCenter().lat],
           });
           marker.setMap(map);
   }
   //搜索数据
   export function autoInput(val) {
     return new Promise((reslove,reject)=>{
         AMap.plugin("AMap.Autocomplete", function () {
       // 实例化Autocomplete
       var autoOptions = {
         city: "全国",
       };
       var autoComplete = new AMap.Autocomplete(autoOptions);
       autoComplete.search(val, function (status, result) {
         // 搜索成功时，result即是对应的匹配数据
         reslove(result)
       });
     });
     })
   }